<template>
	<view
		:style="'order:'+Item.order+';'+Item.css"
		class="list-interact">
		<template v-if="listState == 'success'">
			<view
				@click="$_To('post/post?pid='+item.pid)"
				class="for Flex"
				v-for="item in list">
				<view
					class="left"
					@click.stop="$_To('user/user?uid=' + item.author.uid)">
					<image :src="item.author.avatar" mode="widthFix"></image>
				</view>
				<view class="right">
					<view class="nickname Zt-ShenLanSe">
						{{item.author.nickname?item.author.nickname:'?'}}
						<template v-if="item.author.gender != 1">
							<text
								:style="item.author.gender==3?'color: #ff00ff;':'color: #409EFF;'"
								:class="item.author.gender==3?'iconfont icon-nv':'iconfont icon-nan'"></text>
						</template>
						<text class="P" :style="item.author.nicknameColor?'color:'+item.author.nicknameColor+';':''">{{item.author.roleName}}</text>
					</view>
					<!-- 文字摘要 -->
					<view class="title" v-if="item.title">{{item.title}}</view>
					<view class="content">{{$_filterHtml(item.content)}}</view>
					<!-- 图片 -->
					<template v-if="item.files.images.length">
						<!-- 1张图片 -->
						<template v-if="item.files.images.length == 1">
							<view
								class="file-image-list-1"
								@click.stop="$_picturePreview(index_1,item.files.images)"
								v-for="(images,index_1) in item.files.images">
								<image
									:src="images.imageRatioUrl"
									mode="widthFix"></image>
							</view>
						</template>
						<!-- 2张图片 -->
						<template v-if="item.files.images.length == 2">
							<view class="file-image-list-2">
								<view
									@click.stop="$_picturePreview(index_2,item.files.images)"
									v-for="(images,index_2) in item.files.images">
									<public-lazy-load-image
										:src="images.imageRatioUrl"
										width="100%"
										height="150rpx"
										borderRadius="0">
									</public-lazy-load-image>
								</view>
							</view>
						</template>
						<!-- 3张图片 -->
						<template v-if="item.files.images.length == 3">
							<view class="file-image-list-3">
								<view
									@click.stop="$_picturePreview(0,item.files.images)"
									class="__left">
									<public-lazy-load-image
										:src="item.files.images[0].imageRatioUrl"
										width="100%"
										height="270rpx"
										borderRadius="0">
									</public-lazy-load-image>
								</view>
								<view class="__right">
									<view @click.stop="$_picturePreview(1,item.files.images)">
										<public-lazy-load-image
											:src="item.files.images[1].imageRatioUrl"
											width="100%"
											height="130rpx"
											borderRadius="0">
										</public-lazy-load-image>
									</view>
									<view @click.stop="$_picturePreview(2,item.files.images)">
										<public-lazy-load-image
											:src="item.files.images[2].imageRatioUrl"
											width="100%"
											height="130rpx"
											borderRadius="0">
										</public-lazy-load-image>
									</view>
								</view>
							</view>
						</template>
						<!-- 4张图片 -->
						<template v-if="item.files.images.length == 4">
							<view class="file-image-list-4">
								<view
									@click.stop="$_picturePreview(index_4,item.files.images)"
									v-for="(images,index_4) in item.files.images">
									<public-lazy-load-image
										:src="images.imageRatioUrl"
										width="100%"
										height="150rpx"
										borderRadius="0">
									</public-lazy-load-image>
								</view>
							</view>
						</template>
						<!-- 大于4张图片 -->
						<template  v-if="item.files.images.length > 4">
							<view class="image">
								<view
									class="image-for"
									@click.stop="$_picturePreview(index_more,item.files.images)"
									v-for="(images,index_more) in item.files.images">
									<public-lazy-load-image
										:src="images.imageRatioUrl"
										width="194rpx"
										height="100rpx"
										borderRadius="0">
									</public-lazy-load-image>
								</view>
							</view>
						</template>
					</template>
					<!-- 视频列表 -->
					<view class="video" v-if="!item.files.images.length && item.files.videos.length">
						<view class="image-cover">
							<image :src="item.files.videos[0].videoPosterUrl" mode="widthFix"></image>
						</view>
						<text class="Flex iconfont icon-play"></text>
					</view>
					<view class="group" v-if="item.group || item.hashtags">
						<view class="_group" v-if="item.group">
							<view v-if="item.group.cover"><image :src="item.group.cover" mode="widthFix"></image></view>
							<text>{{item.group.gname}}</text>
						</view>
						<view
							class="_hashtag"
							v-if="item.hashtags">
							#{{item.hashtags[0].hname}}#</view>
						<template v-if="item.operations.diversifyImages.length">
							<template v-for="title in item.operations.diversifyImages">
								<template v-if="title.code == 'title'">
									<view class="_title">
										<view><image :src="title.imageUrl" mode="widthFix"></image></view>
										<text :style="title.description">{{title.name}}</text>
									</view>
								</template>
							</template>
						</template>
					</view>
					<view
						class="post-info Flex"
						:style="!item.previewLikeUsers && !item.previewComments?'margin-bottom: 0;':''">
						<view class="_position" v-if="item.location && item.location.poi">
							<text class="iconfont icon-dingwei1"></text>
							<text class="_position_POI">{{item.location.poi}}</text>
						</view>
						<text class="P">{{item.createdTimeAgo}}</text>
						<view class="type Flex">
							<text class="Bj-LanSe iconfont icon-tupian" v-if="item.files.images.length"></text>
							<text class="Bj-HongSe iconfont icon-zhibo" v-if="item.files.videos.length"></text>
							<text class="Bj-LvSe iconfont icon-yuyin" v-if="item.files.audios.length"></text>
							<text class="Bj-BianKuangSe iconfont icon-gengduo"></text>
						</view>
					</view>
					<view class="like Bj-BeiJingSe" v-if="item.previewLikeUsers">
						<text class="iconfont icon-dianzan"></text>
						<template v-for="like in item.previewLikeUsers">
							<text class="H3">{{like.nickname}},</text>
						</template>
					</view>
					<view class="comment Bj-BeiJingSe" v-if="item.previewComments">
						<template v-for="item_PingLun in item.previewComments">
							<view class="_for">
								<text class="_nickname Zt-ShenLanSe">{{item_PingLun.author.nickname}}:</text>
								<text class="iconfont icon-yuyin" v-if="item_PingLun.files.audios.length"></text>
								<text class="_content">{{$_filterHtml(item_PingLun.content)}}</text>
							</view>
						</template>
					</view>
				</view>
			</view>
			<view
				v-if="Item.page"
				@click="getList('more')"
				class="more">{{listPageText}}</view>
		</template>
		<template v-if="listState == 'loading'">
			<view class="skeleton-screen" v-for="item in Item.query.pageSize?Item.query.pageSize:1">
				<view class="left loading-css"></view>
				<view class="right">
					<view class="loading-css"></view>
					<view class="loading-css"></view>
					<view class="loading-css"></view>
				</view>
			</view>
		</template>
		<template v-if="listState == 'empty'">
			<public-empty></public-empty>
		</template>
	</view>
</template>

<script>
	export default {
		name:"list-interact",
		props:{
			Item:{
				type:Object,
				default:null
			},
			YrConfig:{
				type:String,
				default:""
			},
			listGid:{
				type:String,
				default:""
			},
			listHid:{
				type:String,
				default:""
			}
		},
		data() {
			return {
				list:[],
				listState:"loading",
				listPage:2,
				listPageText:"点击加载更多"
			};
		},
		mounted(){
			this.getList();
		},
		// 卸载组件
		destroyed(){
			
		},
		methods: {
			getList(more){
				if(this.Item.query.gid == 'empty'){
					this.Item.query.gid = "";
					this.listGid = ""
				}
				if(this.Item.query.hid == 'empty'){
					this.Item.query.hid = "";
					this.listHid = ""
				}
				if(more == 'more'){
					this.listPageText = "加载中..."
				}
				this.$_Request(
					"GET","/api/v2/post/list",
					{
						"mapId": this.Item.query.mapId,
						"mapLng": this.Item.query.mapLng,
						"mapLat": this.Item.query.mapLat,
						"uidOrUsername": this.Item.query.uidOrUsername,
						"hid": this.Item.query.hid?this.Item.query.hid:this.listHid,
						"gid": this.Item.query.gid?this.Item.query.gid:this.listGid,
						"includeSubgroups": this.Item.query.includeSubgroups,
						"allDigest": this.Item.query.allDigest,
						"digestState": this.Item.query.digestState,
						"stickyState": this.Item.query.stickyState,
						"contentType": this.Item.query.contentType,
						"createdDays": this.Item.query.createdDays,
						"createdDate": this.Item.query.createdDate,
						"createdDateGt": this.Item.query.createdDateGt,
						"createdDateLt": this.Item.query.createdDateLt,
						"likeCountGt": this.Item.query.likeCountGt,
						"likeCountLt": this.Item.query.likeCountLt,
						"followCountGt": this.Item.query.followCountGt,
						"followCountLt": this.Item.query.followCountLt,
						"blockCountGt": this.Item.query.blockCountGt,
						"blockCountLt": this.Item.query.blockCountLt,
						"commentCountGt": this.Item.query.commentCountGt,
						"commentCountLt": this.Item.query.commentCountLt,
						"orderType": this.Item.query.orderType,
						"orderDirection": this.Item.query.orderDirection,
						"blockGroups": this.Item.query.blockGroups + this.YrConfig,
						"blockHashtags": this.Item.query.blockHashtags,
						"pluginRatingId": this.Item.query.pluginRatingId,
						"pageSize": this.Item.query.pageSize,
						"page":more == 'more' ? this.listPage : "",
						"whitelistKeys":"pid,createdTimeAgo,author.nickname,author.gender,author.nicknameColor,author.roleName,title,content,author.avatar,author.uid,files,group.cover,group.gname,hashtags.0.hname,location,previewLikeUsers.0.nickname,previewLikeUsers.1.nickname,previewLikeUsers.2.nickname,previewLikeUsers.3.nickname,previewLikeUsers.4.nickname,previewLikeUsers.5.nickname,previewLikeUsers.6.nickname,previewLikeUsers.7.nickname,previewLikeUsers.8.nickname,previewLikeUsers.9.nickname,previewComments.0.author.nickname,previewComments.0.files.audios,previewComments.0.content,previewComments.1.author.nickname,previewComments.1.files.audios,previewComments.1.content,previewComments.2.author.nickname,previewComments.2.files.audios,previewComments.2.content,previewComments.3.author.nickname,previewComments.3.files.audios,previewComments.3.content,previewComments.4.author.nickname,previewComments.4.files.audios,previewComments.4.content,previewComments.5.author.nickname,previewComments.5.files.audios,previewComments.5.content,operations"
					},
					(res) => {
						if(more == 'more'){
							if(res.data.data.list.length){
								this.list = this.list.concat(res.data.data.list);
								this.listPage++
								this.listPageText = "点击加载更多"
							}else{
								this.listPageText = "没有数据啦..."
							}
							this.$store.commit('mutationsStateonReachBottomStatus',true)
						}else{
							if(res.data.data.list.length){
								this.list = res.data.data.list;
								this.listState = "success"
							}else{
								this.listState = "empty"
							}
						}
					}
				)
			}
		},
	}
</script>

<style lang="scss" scoped>
.list-interact{
	.for{
		padding: 25rpx 0;
		border-bottom: 1rpx solid $BeiJingSe;
		.left{
			width: 80rpx;
			height: 80rpx;
			overflow: hidden;
			border-radius: 15rpx;
			flex-shrink: 0;
		}
		.right{
			flex: 1;
			margin-left: 25rpx;
			.nickname{
				font-weight: bold;
				.P{
					font-weight: normal;
					padding-left: 15rpx;
				}
				.iconfont{
					font-size: 22rpx;
					font-weight: normal;
					color: $ZhanWeiSe;
				}
			}
			.title{
				font-weight: bold;
				margin-top: 5rpx;
				display: -webkit-box;
				/*!autoprefixer:off*/
				-webkit-box-orient: vertical;
				/*autoprefixer:on*/
				-webkit-line-clamp: 1;
				overflow: hidden;
			}
			.content{
				word-break: break-all;
				margin-top: 5rpx;
				display: -webkit-box;
				/*!autoprefixer:off*/
				-webkit-box-orient: vertical;
				/*autoprefixer:on*/
				-webkit-line-clamp: 3;
				overflow: hidden;
			}
			.image{
				flex-wrap: wrap;
				margin-top: 10rpx;
				width: 100%;
				display: flex;
				.image-for{
					width: 194rpx;
					height: 100rpx;
					margin-top: 10rpx;
					position: relative;
					overflow: hidden;
					border-radius: 10rpx;
				}
				.image-for:nth-child(2),.image-for:nth-child(5),.image-for:nth-child(8){
					margin: 10rpx 10rpx 0 10rpx;
				}
				// #ifdef MP-WEIXIN
				.image-for{
					margin-top: 8rpx;
				}
				.image-for:nth-child(2),.image-for:nth-child(5),.image-for:nth-child(8){
					margin: 8rpx 8rpx 0 8rpx;
				}
				// #endif
			}
			.file-image-list-1{
				margin-top: 10rpx;
				width: 50%;
				image{
					max-width: 100%;
					height: auto;
					border-radius: 10rpx;
					display: block;
				}
			}
			.file-image-list-2{
				margin-top: 10rpx;
				width: 100%;
				display: flex;
				justify-content:space-between;
				overflow: hidden;
				border-radius: 10rpx;
				view{
					width:calc(50% - 5rpx);
					overflow: hidden;
				}
			}
			.file-image-list-3{
				margin-top: 10rpx;
				width: 100%;
				display: flex;
				overflow: hidden;
				border-radius: 10rpx;
				.__left{
					flex: 1;
					height: 270rpx;
					background: #ccc;
					flex-shrink: 0;
					margin-right: 10rpx;
				}
				.__right{
					flex-shrink: 0;
					display: flex;
					justify-content:space-between;
					flex-flow: column;
					view{
						width: 230rpx;
						height: 130rpx;
						background: #DDD;
					}
				}
			}
			.file-image-list-4{
				margin-top: 10rpx;
				display: flex;
				flex-wrap: wrap;
				width: 100%;
				justify-content:space-between;
				overflow: hidden;
				border-radius: 10rpx;
				view{
					width:calc(50% - 5rpx);
					height: 150rpx;
					background: #ddd;
				}
				view:nth-child(3),view:nth-child(4){
					margin-top: 10rpx;
				}
			}
			.video{
				margin-top: 20rpx;
				width: 100%;
				height: 300rpx;
				overflow: hidden;
				border-radius: 10rpx;
				position: relative;
				.image-cover{
					position: absolute;
					top: 0;
					left: 0;
					z-index: 1;
					width: 100%;
					height: 300rpx;
					overflow: hidden;
				}
				.icon-play{
					position: absolute;
					top: 0;
					left: 0;
					z-index: 2;
					width: 100%;
					height: 300rpx;
					align-items: center;
					justify-content: center;
					color: #FFF;
					text-shadow: 0 0 1rpx #000;
					font-size: 100rpx;
					line-height: 100rpx;
					background-color:rgba(0,0,0,0.5);
				}
			}
			.group{
				display: flex;
				align-items: center;
				margin-top: 25rpx;
				._group{
					display: flex;
					align-items: center;
					background: $BeiJingSe;
					border-radius: 100rpx;
					margin-right: 20rpx;
					view{
						width: 45rpx;
						height: 45rpx;
						overflow: hidden;
						border-radius: 100%;
					}
					text{
						font-size: 22rpx;
						line-height: 22rpx;
						padding: 0 20rpx 0 15rpx;
					}
				}
				._hashtag{
					display: flex;
					align-items: center;
					border-radius: 100rpx;
					height: 45rpx;
					background: $BeiJingSe;
					font-size: 22rpx;
					line-height: 22rpx;
					padding: 0 15rpx;
					margin-right: 20rpx;
				}
				._title{
					display: flex;
					align-items: center;
					background: $BeiJingSe;
					border-radius: 100rpx;
					margin-right: 20rpx;
					view{
						width: 45rpx;
						height: 45rpx;
						overflow: hidden;
						border-radius: 100%;
						display: flex;
						align-items: center;
						justify-content: center;
					}
					text{
						font-size: 22rpx;
						line-height: 22rpx;
						padding: 0 20rpx 0 15rpx;
					}
				}
			}
			.post-info{
				margin: 25rpx 0;
				align-items: center;
				._position{
					display: flex;
					align-items: center;
					line-height: 22rpx;
					margin-right: 10rpx;
					text{
						font-size: 22rpx;
						line-height: 22rpx;
						color: $ZhanWeiSe;
					}
					.iconfont{
						margin-right: 5rpx;
					}
					._position_POI{
						max-width: 350rpx;
						display: -webkit-box;
						/*!autoprefixer:off*/
						-webkit-box-orient: vertical;
						/*autoprefixer:on*/
						-webkit-line-clamp: 1;
						overflow: hidden;
					}
				}
				.type{
					flex: 1;
					align-items: center;
					justify-content: flex-end;
					text{
						margin-left: 10rpx;
						color: #FFF;
						font-size: 18rpx;
						line-height: 18rpx;
						padding: 5rpx;
						border-radius: 2rpx;
					}
					.icon-gengduo{
						display: flex;
						align-items: center;
						justify-content: center;
						color: $YuanSe;
						padding: 0 10rpx;
						height: 26rpx;
					}
				}
			}
			.like{
				padding: 15rpx 20rpx;
				line-height: 38rpx;
				border-bottom: 1px solid $BianKuangSe;
				text{
					color: $ShenLanSe;
				}
				.icon-dianzan{
					font-size: 32rpx;
					padding: 0 5rpx 0 0;
					position: relative;
					top: .5rpx;
				}
				.H3{
					line-height: 38rpx;
					margin-right: 10rpx;
					word-wrap: break-word;
					word-break: normal;
				}
			}
			.comment{
				padding: 10rpx 0 15rpx 0;
				border-radius: 10rpx;
				._for{
					padding: 5rpx 25rpx 0 25rpx;
					line-height: 40rpx;
					display: -webkit-box;
					/*!autoprefixer:off*/
					-webkit-box-orient: vertical;
					/*autoprefixer:on*/
					-webkit-line-clamp: 3;
					overflow: hidden;
					text{
						font-size: 28rpx;
					}
					._nickname{
						flex-shrink: 0;
						padding-right: 10rpx;
					}
					.icon-yuyin{
						font-size: 22rpx;
						line-height: 22rpx;
						padding-right: 5rpx;
						color: $LvSe;
					}
					._content{
						word-break: break-all;
					}
				}
			}
		}
	}
	.more{
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		line-height: 28rpx;
		color: $ZhanWeiSe;
		padding: 35rpx 0;
	}
}
.skeleton-screen{
	display: flex;
	border-bottom: 1rpx solid $BeiJingSe;
	padding: 25rpx 0;
	.left{
		width: 80rpx;
		height: 80rpx;
		overflow: hidden;
		border-radius: 15rpx;
		flex-shrink: 0;
	}
	.right{
		flex: 1;
		margin-left: 25rpx;
		view:nth-child(1){
			width: 100%;
			height: 40rpx;
		}
		view:nth-child(2){
			width: 100%;
			height: 120rpx;
			margin: 15rpx 0;
		}
		view:nth-child(3){
			width: 100%;
			height: 150rpx;
		}
	}
}
</style>